Colin Walters [Fri, 2 Jun 2017 13:27:52 +0000 (09:27 -0400)]
Revert "Add a notion of "physical" sysroot, use for remote writing"
This reverts commit
1eff3e83436b6129c0dc350dbbda52ba330e3834. There
are a few issues with it. It's not a critical thing for now, so
let's ugly up the git history and revisit when we have time to
debug it and add more tests.
Besides the below issue, I noticed that the simple `ostree remote add`
now writes to `/ostree/repo/config` because we *aren't* using the
`--sysroot` argument.
Closes: https://github.com/ostreedev/ostree/issues/901
Closes: #902
Approved by: mike-nguyen
Krzesimir Nowak [Fri, 2 Jun 2017 12:50:29 +0000 (14:50 +0200)]
lib/sysroot: Document the NO_CLEAN flag
Closes: #900
Approved by: jlebon
Colin Walters [Thu, 1 Jun 2017 19:55:15 +0000 (15:55 -0400)]
lib/repo: Delete unused private prototypes
The implementations were removed in:
6ffcb24d227eae5a479caf45adb8037eceb6ae33
I noticed this while looking at the commit code.
Closes: #898
Approved by: jlebon
Colin Walters [Tue, 23 May 2017 20:18:31 +0000 (16:18 -0400)]
repo/commit: Split up metadata/content commit paths
There was a lot of conditionals inside `write_object()` differentating
between metadata/content, and then for content, on the different repo
types. Further, in the metadata path since the logic is simpler, can
present a non-streaming API, and further use `OtTmpfile`, etc.
Splitting them up helps drop a lot of conditionals. We introduce a small
`CleanupUnlinkat` that allows us to fully convert to the new code style in both
functions.
This itself is still prep for fully switching to `GLnxTmpfile`.
Closes: #881
Approved by: jlebon
Colin Walters [Tue, 23 May 2017 19:13:08 +0000 (15:13 -0400)]
repo/commit: Don't renormalize trusted metadata
As the comment in the code says; in the expected checksum case, the caller
really has to have a normal form already.
Closes: #881
Approved by: jlebon
Colin Walters [Tue, 23 May 2017 19:04:50 +0000 (15:04 -0400)]
repo/commit: In the expected checksum case, check existence early
If we have an expected checksum, call `fstatat(repo_dfd, checksum)`
early on before we do much else. This actually duplicates code,
but future work here is going to split up the metadata/content
commit paths, so they'll need to diverge anyways.
Closes: #881
Approved by: jlebon
Colin Walters [Tue, 23 May 2017 18:58:03 +0000 (14:58 -0400)]
repo/commit: Dedup content writing API implementation
Similar to metadata, for `write_content_trusted()` we can just
call `_write_content()` with a `NULL` output checksum.
Closes: #881
Approved by: jlebon
Colin Walters [Tue, 23 May 2017 18:49:17 +0000 (14:49 -0400)]
repo/commit: Dedup metadata writing API implementations
First, the streaming metadata API is pretty dumb, since metadata
should be small. Really we should have supported a `GBytes`
version. Currently, this API *is* used when we do local pulls,
so this commit has test coverage. However, I plan to change
the object import to avoid using this. But that's fine, since
I can't think of why someone would use this API.
Next, the only difference between `ostree_repo_write_metadata()` and
`ostree_repo_write_metadata_trusted()` is whether or not we pass
an output checksum; so just dedup the implementations.
Also while I'm here break out the input length validation and do
it early in the streaming case.
Closes: #881
Approved by: jlebon
Colin Walters [Tue, 30 May 2017 18:07:13 +0000 (14:07 -0400)]
Add a notion of "physical" sysroot, use for remote writing
Using `${sysroot}` to mean the physical storage root: We don't want to write to
`${sysroot}/etc/ostree/remotes.d`, since nothing will read it, and really
`${sysroot}` should just have `/ostree` (ideally). Today the Anaconda rpmostree
code ends up writing there. Fix this by adding a notion of "physical" sysroot.
We determine whether the path is physical by checking for `/sysroot`, which
exists in deployment roots (and there shouldn't be a `${sysroot}/sysroot`).
In order to unit test this, I added a `--sysroot` argument to `remote add`.
However, doing this better would require reworking the command line parsing for
the `remote` argument to support specifying `--repo` or `--sysroot`, and I
didn't quite want to do that yet in this patch.
Closes: https://github.com/ostreedev/ostree/issues/892
Closes: #896
Approved by: jlebon
Colin Walters [Tue, 30 May 2017 17:04:18 +0000 (13:04 -0400)]
lib/util: Some style conversion
I saw a few instances of `glnx_set_error_from_errno() + return FALSE`,
and fixed them and did a bit of style conversion.
Closes: #895
Approved by: jlebon
Colin Walters [Fri, 26 May 2017 21:53:49 +0000 (17:53 -0400)]
cmd: Use autoptr for GKeyFile
Prep for code style conversion.
Closes: #891
Approved by: jlebon
Colin Walters [Fri, 26 May 2017 18:35:34 +0000 (14:35 -0400)]
tree-wide: Add+run spatch to use glnx_throw()
I had to run a sed job to add whitespace after, but otherwise this was easy.
Closes: #890
Approved by: jlebon
Colin Walters [Thu, 25 May 2017 23:38:52 +0000 (19:38 -0400)]
lib/sysroot: Add non-failable ostree_sysroot_repo()
Having a failable accessor is annoying, since it's really common
to reference both. Instead, open the repo once when we load
the sysroot, and provide a non-failable accessor.
This is also prep for `ostree_repo_open_at()`, which collapses the separation
between `ostree_repo_new()` and `ostree_repo_open()`.
Closes: #886
Approved by: jlebon
Colin Walters [Thu, 25 May 2017 21:26:42 +0000 (17:26 -0400)]
lib: Add an "is_system" member to OstreeRepo
This is prep for introducing a fd-relative `ostree_repo_new_at()`.
Previously, `ostree_repo_is_system()` compared `GFile` paths, but
there's a much simpler check we can do first - if this repository
was created via `OstreeSysroot`, it must be a system repo.
Closes: #886
Approved by: jlebon
Colin Walters [Fri, 26 May 2017 17:41:12 +0000 (13:41 -0400)]
lib/fsutil: Port to new code style
Pretty trivial.
Closes: #889
Approved by: jlebon
Colin Walters [Fri, 26 May 2017 17:40:14 +0000 (13:40 -0400)]
lib/fsutil: Delete unused GFile ioctl method
All the deployment code uses fds.
Closes: #889
Approved by: jlebon
Colin Walters [Fri, 26 May 2017 14:22:52 +0000 (10:22 -0400)]
pull-test: Add some 404 tests
See: https://github.com/flatpak/flatpak/issues/816
Closes: #887
Approved by: jlebon
Jonathan Lebon [Thu, 25 May 2017 16:28:15 +0000 (12:28 -0400)]
PAPR: migrate to the new name
The redhat-ci service has been renamed to PAPR. Previous values are
still supported though should be considered deprecated.
Closes: #885
Approved by: cgwalters
Colin Walters [Wed, 24 May 2017 20:43:39 +0000 (16:43 -0400)]
tests: Add some C tests for object writing
Prep for https://github.com/ostreedev/ostree/pull/881
Closes: #884
Approved by: jlebon
Colin Walters [Fri, 17 Mar 2017 21:18:27 +0000 (17:18 -0400)]
lib/deploy: Port config merge logic to new code style
This is a de-scoping of work I did in preparation for
rpm-ostree [live updates](https://github.com/projectatomic/rpm-ostree/pull/652).
Originally I was going to expose this as a public API.
However, I decided to do things differently, but the cleanup here for new code
style and fd-relative is nice to have anyways.
We rework things to use `OstreeDeployment*`, which the caller is expected to
already have, rather than `GFile*`s pointing to the config directories.
Closes: #741
Approved by: jlebon
Alexander Larsson [Wed, 24 May 2017 09:12:05 +0000 (11:12 +0200)]
fetcher: Send Accept-Encoding: gzip when downloading summary
The summary file can get large, but it compresses well (something
which is not true of other files in the ostree repo which are
already compressed). By sending Accept-Encoding: gzip (and
handling the compressed results) we send a lot less data.
I set up the flathub repo (http://flathub.org/repo) to enable
gzip for the summary file (only), and the result is that the
331514 byte large summary was transferred in 122889 bytes.
On my (fast) network this decreased the time i took to do
"flatpak remote-ls flathub" by about 100msec.
This fixes https://github.com/ostreedev/ostree/issues/802
Closes: #882
Approved by: cgwalters
Philip Withnall [Tue, 23 May 2017 12:26:25 +0000 (13:26 +0100)]
build: Use AM_TESTS_ENVIRONMENT rather than TESTS_ENVIRONMENT
TESTS_ENVIRONMENT is reserved for the user to be able to set when
running the tests. AM_TESTS_ENVIRONMENT is for the tests’ Makefile to
set itself.
https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #880
Approved by: cgwalters
Colin Walters [Wed, 17 May 2017 15:02:56 +0000 (11:02 -0400)]
Add stub for new libglnx tmpfile API, port simpler callers to it
It's hard right now to do a full port to the new libglnx tmpfile
API since there are complex cases in the commit path which deal
with symlinks as well.
Let's make things more gradual by introducing the important part (struct with
autocleanup) here in libotutil, port what we can. This will make a future
complete port easier.
Closes: #871
Approved by: jlebon
Colin Walters [Mon, 15 May 2017 21:24:52 +0000 (17:24 -0400)]
bin/cookies: Delete dead tmpfile code in cookie list command
This was a copy-paste-o.
Closes: #871
Approved by: jlebon
Daniel Drake [Mon, 15 May 2017 18:13:38 +0000 (12:13 -0600)]
Allow commits to mark refs as EOL, replaced by others
A commit can now include a "ostree.endoflife-rebase" metadata key
pointing to a new ref.
When updating, the sysroot upgrader will see this and proceed to
pull and deploy the new ref instead. The origin file in the new
deployment will point to the new ref.
This functionality is planned to be used in Endless OS. We will create
a lesser tested branch for brand new, cutting edge hardware support,
and ship that on hardware platforms that require the latest drivers.
However, once our slower-moving official release is later updated to
support the new hardware, we will use this functionality to migrate
those bleeding-edge users over to the official release.
Closes: #874
Approved by: cgwalters
Daniel Drake [Wed, 3 May 2017 15:36:48 +0000 (09:36 -0600)]
libtest: allow committing to alternative branches
This will be used by the upcoming test-admin-upgrade-endoflife.sh
Closes: #874
Approved by: cgwalters
Colin Walters [Fri, 19 May 2017 17:10:45 +0000 (13:10 -0400)]
tests/libtest-core: Copy rpm-ostree changes, clean up
I want to keep this a "pure copy-able" file into various projects
like rpm-ostree, bwrap, and flatpak. Pull in changes from rpm-ostree
to prep for that.
While we have the patient open, dedup the code for file matching a bit.
Closes: #877
Approved by: jlebon
Colin Walters [Fri, 19 May 2017 14:39:48 +0000 (10:39 -0400)]
ci: Add unit case for --enable-experimental-api
We're starting to get a lot of contexts, and this is likely going to drive some
requirements for consolidation and improvements like not testing *every* context
on every PR, etc.
But for now since experimental is new, and under development, let's test it.
Closes: #875
Approved by: cgwalters
Colin Walters [Fri, 19 May 2017 15:00:34 +0000 (11:00 -0400)]
tests/test-symbols.sh: Fix with --enable-experimental-api
We missed a `--no-filename` for grep with the documentation.
Closes: #875
Approved by: cgwalters
Philip Withnall [Fri, 19 May 2017 09:11:35 +0000 (10:11 +0100)]
lib/remote: Fix compilation with --enable-experimental-api
The whole ostree-remote.h file is only included in the public ostree.h
header if OSTREE_ENABLE_EXPERIMENTAL_API is defined, so there’s no need
to change the set of methods defined in it according to whether we’re
compiling with experimental API.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #875
Approved by: cgwalters
Philip Withnall [Thu, 18 May 2017 07:28:03 +0000 (08:28 +0100)]
lib/repo: Make ost_repo_remove_remote() available internally
Make it an internal, not static, API; like _ostree_repo_add_remote(). It
will be used in many the same situations.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #875
Approved by: cgwalters
Philip Withnall [Thu, 18 May 2017 07:26:34 +0000 (08:26 +0100)]
lib/repo: Add return value to _ostree_repo_add_remote()
Return whether the remote already existed. This is an internal API, so
it’s not an API break. The return value will be useful in upcoming
commits for working out whether to later remove a remote again.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #875
Approved by: cgwalters
Philip Withnall [Thu, 18 May 2017 07:17:29 +0000 (08:17 +0100)]
lib/remote: Add arguments to internal OstreeRemote constructor
Add a name argument to the internal OstreeRemote constructor,
since this member (and several derived from it) is non-nullable,
and hence must always be set at construction time.
This changes the only call sites of the constructor to use the new API,
which is internal.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #875
Approved by: cgwalters
Philip Withnall [Thu, 18 May 2017 07:16:18 +0000 (08:16 +0100)]
lib/remote: Add internal annotations to OstreeRemote
Just for internal documentation; g-ir-scanner doesn’t read or understand
them.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #875
Approved by: cgwalters
Philip Withnall [Thu, 18 May 2017 07:11:32 +0000 (08:11 +0100)]
lib/remote: Add a getter for OstreeRemote.name
Now that we’ve got a public, sealed OstreeRemote structure, we can start
carefully exposing members of it as API.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #875
Approved by: cgwalters
Jonathan Lebon [Wed, 17 May 2017 15:41:54 +0000 (11:41 -0400)]
pull: complete detached meta fetch before scanning
If somehow a repo has gpg verification on but doesn't have signatures
present for the existing commit, ostree would error out if it needs to
scan the commit object (e.g. if there are no updates available).
An instance of this is currently happening in Fedora AH, in which
signatures are not shipped in the ISO due to filesystem restrictions.
Another possible scenario is if a content provider switches from not
signing commits to signing them; even if older commits are retroactively
signed, clients' local commit objects would error out if they needed
scanning.
This patch adds a check to ensure that we always attempt to fetch the
detached metadata and wait for its result (whether it exists or not)
before moving on to scan their corresponding commit objects.
See also: https://github.com/projectatomic/rpm-ostree/issues/630
Closes: #873
Approved by: cgwalters
Colin Walters [Tue, 16 May 2017 16:02:25 +0000 (12:02 -0400)]
Release 2017.6
There's already a lot queued. In particular this brings some API
additions that rpm-ostree depends on.
Closes: #865
Approved by: jlebon
Colin Walters [Wed, 17 May 2017 13:55:34 +0000 (09:55 -0400)]
lib/pull: Port some functions to new code style
Porting a lot of this file would be hard since in many cases we do processing in
the `out:` section, so let's do what we can.
Closes: #870
Approved by: jlebon
Colin Walters [Wed, 17 May 2017 01:44:22 +0000 (21:44 -0400)]
switchroot/generator: Add var.mount to local-fs.target.requires
Unbreaks mounting in CentOS. Newer systemd in Fedora pulls didn't need this, I
think due to `RequiresMountsFor=`. Anyways, this is what the fstab generator
does, and it's clearly right ✓.
Closes: https://github.com/ostreedev/ostree/issues/867
Closes: #869
Approved by: jlebon
Colin Walters [Wed, 17 May 2017 01:46:22 +0000 (21:46 -0400)]
build: Use cd $(srcdir) instead of `git -C`
Since the version in CentOS is too old, and we get a spam of warnings, plus
things like detecting the git repo break.
Fixes: 50f73cbac35be97fd5895531e295d05dabaa8ed9
Closes: #868
Approved by: jlebon
Colin Walters [Tue, 16 May 2017 15:30:35 +0000 (11:30 -0400)]
lib/upgrader: Port to new code style
No surprises here. Prep for future work.
Closes: #864
Approved by: jlebon
Colin Walters [Tue, 16 May 2017 14:51:40 +0000 (10:51 -0400)]
lib: Add "open dfd iter handling noent" helper, port tree-wide
Follow up to a previous patch that addressed a double-close; I
realized we already had a helper for doing "open dfd iter, do nothing
if we get ENOENT". Raise it to libotuil, and port all consumers.
Closes: #863
Approved by: jlebon
Colin Walters [Tue, 16 May 2017 16:42:45 +0000 (12:42 -0400)]
tree-wide: Add a few missing O_CLOEXEC
I noticed an instance of this while working on https://github.com/ostreedev/ostree/pull/861
Which apparently I cargo-culted into the new system generator bits.
Let's break this out as a small concise change.
Closes: #866
Approved by: jlebon
Colin Walters [Thu, 11 May 2017 18:54:12 +0000 (14:54 -0400)]
Switch to using a systemd generator for /var
If one wants to set up a mount for `/var` in `/etc/fstab`, it
won't be mounted since `ostree-prepare-root` set up a bind mount for
`/var` to `/sysroot/ostree/$stateroot/var`, and systemd will take
the already extant mount over what's in `/etc/fstab`.
There are a few options to fix this, but what I settled on is parsing
`/etc/fstab` in a generator (exactly like `systemd-fstab-generator` does),
except here we look for an explicit mount for `/var`, and if one *isn't* found,
synthesize the default ostree mount to the stateroot. Another nice property is
that if an admin creates a `var.mount` unit in `/etc` for example, that will
also override our mount.
Note that today ostree doesn't hard depend on systemd, so this behavior only
kicks in if we're built with systemd *and* libmount support (for parsing
`/etc/fstab`). I didn't really test that case though.
Initially I started writing this as a "pure libc" program, but at one point
decided to use `libostree.so` to find the booted deployment. That didn't work
out because `/boot` wasn't necessarily mounted and hence we couldn't find the
bootloader config. A leftover artifact from this is that the generator code
calls into libostree via the "cmd private" infrastructure. But it's an easy way
to share code, and doesn't hurt.
Closes: #859
Approved by: jlebon
Colin Walters [Mon, 15 May 2017 17:59:57 +0000 (13:59 -0400)]
switchroot/remount: Check mount status before remounting, be verbose
By checking the mount status, we avoid remounting things if we don't
need to. And printing a single line per mount helps debugging when
things go wrong.
Closes: #859
Approved by: jlebon
Colin Walters [Fri, 12 May 2017 19:55:12 +0000 (15:55 -0400)]
switchroot/remount: Trim set of remounted filesystems
I really have no idea what I was thinking with that list of mount points. It
seems arbitrary. Sadly `git log` doesn't help, and there's no comments.
Basically, the only mounts we should care about are those that libostree
creates. Which are just `/sysroot` and `/var`. Systemd will handle the other
things like `/tmp`, it's not our job, and we shouldn't touch them.
Closes: #859
Approved by: jlebon
Colin Walters [Tue, 16 May 2017 13:57:31 +0000 (09:57 -0400)]
lib/repo: Fix double close()
Should probably change `_take_fd()` to take a pointer and set to `-1`
at some point.
Regression from
8d58ab1002cbc4a1ecafe3d1a80984f8a60f41e9
Closes: #862
Approved by: jlebon
Colin Walters [Mon, 15 May 2017 13:10:54 +0000 (09:10 -0400)]
lib/remote: Box OstreeRemote if experimental-api
To avoid an introspection warning. Otherwise, don't box it.
Closes: #858
Approved by: pwithnall
Colin Walters [Fri, 12 May 2017 19:34:52 +0000 (15:34 -0400)]
remount: Drop support for auto-tmpfs-on-var; use systemd.volatile=state
In current systemd, there is:
[systemd-volatile-root](https://www.freedesktop.org/software/systemd/man/systemd-volatile-root.service.html)
which was introduced by [this commit](https://github.com/systemd/systemd/commit/
91214a37ef4eb8042d2598aa89bae52b410d11a7).
I'd like to make further changes to how we handle `/var`, and I don't
want to reason about the interaction of our "tmpfs var" with too many
other things.
The comment about having "all /var handling in one place" was always inaccurate
given that we rely on systemd for mounting. And in general, I don't want to
duplicate too many things systemd does - it does them well, documents them, etc.
As far as I know, it was basically just Owen who was using this for the GNOME
hardware testing effort, and I'm sure he could easily switch over to
`systemd.volatile=state`.
Closes: #856
Approved by: owtaylor
Jonathan Lebon [Fri, 12 May 2017 18:17:21 +0000 (14:17 -0400)]
libglnx: bump and use new helper methods
Update submodule: libglnx
Closes: #857
Approved by: cgwalters
Jonathan Lebon [Fri, 12 May 2017 18:14:22 +0000 (14:14 -0400)]
tests/ci-commitmessage-submodules.sh: fix for RHCI
Special-case when this script is run under RHCI, which will try to fetch
the merge commit if possible. Use RHCI_COMMIT instead to refer to the
actual PR/branch HEAD being evaluated.
Use realpath to workaround the developer's git dir being in a symbolic
link.
Closes: #857
Approved by: cgwalters
Colin Walters [Fri, 12 May 2017 00:29:21 +0000 (20:29 -0400)]
lib/checkout: Fix regression in subpath for regular files
This is what caused the merge of
https://github.com/projectatomic/rpm-ostree/pull/652
to blow up, since https://github.com/ostreedev/ostree/pull/848
landed right before we tried to merge it.
When I was writing that PR I remember having an uncertain feeling
since we were doing a `mkdirat` above, but at the time I thought
we'd have test suite coverage...turns out we didn't.
For backwards compatibility, we need to continue to do a `mkdirat` here of the
parent. However...I can't think of a reason anyone would *want* that behavior.
Hence, let's add a special trick - if the destination name is `.`, we skip
`mkdirat()`. That way rpm-ostree for example can open a dfd for `/etc` and avoid
the `mkdir`.
Fold the subpath tests into `test-basic.sh` since it's not worth a separate
file. Add a test case for checking out a file.
Closes: #854
Approved by: jlebon
Colin Walters [Thu, 11 May 2017 14:59:21 +0000 (10:59 -0400)]
tree-wide: Switch tabs ⭾ in various files over to spaces ␠
As $DEITY intended.
I was reading the `prepare-root.c` code and the indentation damage was
distracting. Squash tabs that have leaked into various places in the code. I
didn't yet touch the `src/libostree` bits as that has higher potential for
conflict.
Closes: #852
Approved by: jlebon
Colin Walters [Thu, 11 May 2017 13:08:20 +0000 (09:08 -0400)]
checkout: Plug a memleak of the state stringbuf
A struct without a cleanup macro is a struct likely to leak.
Closes: #850
Approved by: jlebon
Colin Walters [Thu, 11 May 2017 02:19:14 +0000 (22:19 -0400)]
lib/repo: Port more of GPG and summary functions to new code style
These ones were pretty easy, not sure why I didn't do them in an earlier pass.
Closes: #849
Approved by: jlebon
Colin Walters [Thu, 11 May 2017 02:21:27 +0000 (22:21 -0400)]
repo: Fix double close() in summary generation
Happened to notice this while doing a style port.
Closes: #849
Approved by: jlebon
Colin Walters [Thu, 11 May 2017 01:40:50 +0000 (21:40 -0400)]
lib/checkout: Optimize checkout by avoiding OstreeRepoFile recusion
Looking at `perf record ostree checkout`, some things stand out; e.g.:
```
+ 27.63% 0.07% ostree libgio-2.0.so.0.5000.3 [.] g_file_enumerator_iterate
+ 22.74% 0.28% ostree libostree-1.so.1.0.0 [.] ostree_repo_file_tree_query_child
+ 13.74% 0.08% ostree libostree-1.so.1.0.0 [.] ot_variant_bsearch_str
```
The GIO abstractions are already fairly heavyweight, and `OstreeRepoFile` mallocs
a lot too.
Make things more efficient here by dropping the GIO bits for reading ostree data -
we just read from the variants directly and iterate over them. The end result
here is that according to perf we go from ~40% of our time in the kernel to
~70%, and things like `g_file_enumerator_iterate()` drop entirely out of the
hot set.
Closes: #848
Approved by: jlebon
Colin Walters [Thu, 11 May 2017 01:43:26 +0000 (21:43 -0400)]
lib/checkout: Move special case for subpath of file to toplevel
Since we now have a cleaner separation of "toplevel checkout prep"
versus "recursive checkout", handle the special case of checking out
a single file at first rather than later.
Prep for future work in optimizing this function more.
Closes: #848
Approved by: jlebon
Colin Walters [Wed, 10 May 2017 15:08:12 +0000 (11:08 -0400)]
lib/prune: Complete porting to new code style
Only non-mechanical bit here was creating a local autoptr for a bit
where we'd previously done an unref for a struct member.
Closes: #847
Approved by: jlebon
Colin Walters [Thu, 27 Apr 2017 18:24:20 +0000 (14:24 -0400)]
checkout/commit: Use glnx_regfile_copy_bytes() if possible
Rather than `g_output_stream_splice()`, where the input is a regular
file.
See https://github.com/GNOME/libglnx/pull/44 for some more information.
I didn't try to measure the performance difference, but seeing the
read()/write() to/from userspace mixed in with the pointless `poll()` annoyed me
when reading strace.
As a bonus, we will again start using reflinks (if available) for `/etc`,
which is a regression from the https://github.com/ostreedev/ostree/pull/797
changes (which before used `glnx_file_copy_at()`).
Also, for the first time we'll use reflinks when doing commits from file-backed
content. This happens in `rpm-ostree compose tree` today for example.
Update submodule: libglnx
Closes: #817
Approved by: jlebon
Colin Walters [Tue, 9 May 2017 19:55:03 +0000 (15:55 -0400)]
sysroot: More porting to new code style
This isn't all of this file yet, just doing another chunk.
Closes: #845
Approved by: jlebon
Colin Walters [Tue, 9 May 2017 17:39:51 +0000 (13:39 -0400)]
diff: Port some to new code style
Continuing to chip away at this. Using `g_file_enumerator_iterate()`
here helps notably.
I started on the much bigger `ostree_diff_dirs_with_options()` but
it's a lot messier - for later.
Closes: #844
Approved by: jlebon
Colin Walters [Tue, 9 May 2017 15:52:20 +0000 (11:52 -0400)]
ci: Move travis scripts from tests/ → ci/
I think tests/ should be just that, ci/ is separate. Also rename
the files to include "travis" since that's what we use them
for right now.
Closes: #843
Approved by: jlebon
Colin Walters [Mon, 1 May 2017 22:02:27 +0000 (18:02 -0400)]
ci: More flatpak ci fixes
We need our `make install` to override the ostree RPM, so do it all in one txn.
This sort of thing is where a more rigorous model like rdgo/gcontinuous use
becomes better, but we'll hack it with shell for now.
Closes: #824
Approved by: jlebon
Colin Walters [Mon, 8 May 2017 20:44:42 +0000 (16:44 -0400)]
ci: Extend FAH rootfs for installed tests
These at the moment aren't in a container, and may need space. In the future
overlay2 will help here, we can more easily extend the rootfs.
Closes: #840
Approved by: jlebon
Colin Walters [Mon, 8 May 2017 17:37:50 +0000 (13:37 -0400)]
tests: Migrate test-pull-many.sh to installed on FAH
`test-pull-many.sh` is was just too slow to be a unit test. Generating
a bunch of files via shell is slow, the delta generation is slow, etc.
Every developer doesn't need to run it every time.
Somewhat address this by converting it into our installed test framework, which
moves it out of the developer fast paths. Another advantage to this is
that we can simply reuse the FAH tree content rather than synthesizing
new bits each time.
Closes: #840
Approved by: jlebon
Colin Walters [Mon, 8 May 2017 15:20:32 +0000 (11:20 -0400)]
tests: For installed, s/test-/itest-/ to avoid in-tree name clashes
I want to migrate `test-pull-many.sh` → `itest-pull.sh`, hence not
conflicting with the unit test `test-pull.sh.
Closes: #840
Approved by: jlebon
Colin Walters [Mon, 8 May 2017 20:59:14 +0000 (16:59 -0400)]
fsck: Check for refs missing corresponding commit
Just doing this one quickly since it was easy.
Closes: https://github.com/ostreedev/ostree/issues/831
Closes: #841
Approved by: jlebon
Colin Walters [Tue, 9 May 2017 13:26:11 +0000 (09:26 -0400)]
utils/checksum: Port to new code style
Just happened to be reading this code, it's an easy port.
Closes: #842
Approved by: jlebon
Philip Withnall [Sun, 7 May 2017 19:57:53 +0000 (20:57 +0100)]
build: Add -C arguments to some git invocations
This moves the build system a little closer towards being safe for
builddir ≠ srcdir.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #832
Approved by: cgwalters
Philip Withnall [Fri, 21 Apr 2017 15:25:23 +0000 (16:25 +0100)]
libostree: Make OstreeRemote a public and internal API
Previously it was static to ostree-repo.c. Make it usable throughout
libostree so it can be used by an upcoming commit, but also expose the
typedef and reference counting functions so that opaque OstreeRemote
pointers can be used by user code, in anticipation of exposing more of
its API publicly in future.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #832
Approved by: cgwalters
Philip Withnall [Mon, 8 May 2017 15:14:50 +0000 (16:14 +0100)]
libostree: Expose $OSTREE_FEATURES in the pkg-config file
This allows consumers of libostree to check at configure time whether it
supports the feature they want.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #832
Approved by: cgwalters
Philip Withnall [Mon, 1 May 2017 09:59:33 +0000 (10:59 +0100)]
build: Add --enable-experimental-api configure option for unstable APIs
There are currently no unstable APIs, but some will be added in
following commits. They will be built and exposed in the libostree
global symbol list iff configured with --enable-experimental-api.
Distributions should not package OSTree with --enable-experimental-api.
This is designed for previewing new APIs on controlled platforms; any of
the APIs hidden behind this option may be changed or removed at any
point.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #832
Approved by: cgwalters
Colin Walters [Mon, 8 May 2017 14:44:43 +0000 (10:44 -0400)]
Add --enable-installed-tests=exclusive, fix installed case
The major reason to do this is that running tests *both* installed
and uninstalled in our CI is a mostly pointless waste of time.
Particularly given we have a few expensive tests.
We *do* have tests that only run uninstalled (since they require
the source code) like `test-symbols.sh`.
Hence, add `--enable-installed-tests=exclusive` to mean *only* do installed for
most tests.
We'll still have uninstalled coverage via the Travis/Debian configs, and we
could perhaps do another build with a subset of uninstalled tests, but I'm not
really concerned about it.
I'd like to do a renewed push for the InstalledTests model since
I feel it's just fundamentally better. (`g-d-t-r` kind of sucks,
but then so does the automake runner).
Also while we're here - fix the CI to use the correct context,
which started this mess.
Closes: #837
Approved by: dbnicholson
Dan Nicholson [Thu, 4 May 2017 19:58:07 +0000 (14:58 -0500)]
tests: Look for trivial-httpd in $libexecdir
Since
b825aac, trivial-httpd is in $libexecdir/libostree by default and
not available through the ostree runner in PATH. Try to adjust find it
when running the tests installed.
Closes: #837
Approved by: dbnicholson
Dan Nicholson [Thu, 4 May 2017 19:16:21 +0000 (14:16 -0500)]
tests: Install libtest-core.sh with installed tests
Without this, running the installed tests fails dramatically. Remove it
from EXTRA_DIST since dist_installed_test_data takes care of dist.
Closes: #837
Approved by: dbnicholson
Philip Withnall [Mon, 8 May 2017 15:04:26 +0000 (16:04 +0100)]
tests: Fix regex escaping in test-summary-view.sh
There were some regex special characters in the pattern strings, which I
think were causing the test to fail on some Travis builds due to using
an invalid regex.
Fix that by matching using fixed strings instead. We don’t need regexes
here. Use a new assert_file_has_content_literal to do that for us.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #838
Approved by: cgwalters
Dan Nicholson [Mon, 8 May 2017 14:46:35 +0000 (09:46 -0500)]
pull: Allow additional HTTP headers for summary fetch
Read the http-headers (a(ss)) option in
ostree_repo_remote_fetch_summary_with_options like
ostree_repo_pull_with_options and add the headers to the fetcher. This
allows things like providing additional authorization headers to the
HTTP requests.
Closes: #839
Approved by: cgwalters
Dan Nicholson [Thu, 4 May 2017 19:10:57 +0000 (14:10 -0500)]
commit: Mark ostree_repo_transaction_set_ref* checksums nullable
Allow GI bindings to delete refs through ostree_repo_transaction_set_ref
and ostree_repo_transaction_set_refspec by setting the checksum to NULL.
Closes: #834
Approved by: cgwalters
Philip Withnall [Sun, 7 May 2017 17:55:29 +0000 (18:55 +0100)]
tests: Add a test for `ostree summary --view`
This includes a test of the new human-readable key names.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #826
Approved by: cgwalters
Philip Withnall [Fri, 5 May 2017 10:28:42 +0000 (11:28 +0100)]
ostree: Use #defines for well-known metadata key names
Rather than hard-coding the names as strings. This makes the code a
little more maintainable.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #826
Approved by: cgwalters
Philip Withnall [Thu, 4 May 2017 10:32:46 +0000 (11:32 +0100)]
ostree: Improve formatting for well-known summary metadata keys
If a summary metadata key is well-known, like ostree.static-deltas, or
ostree.summary.last-modified, format it a little more nicely.
This is especially important for timestamps like last-modified, since
otherwise they’re formatted as a big-endian uint64, which is basically
unusable for the user.
Non-formatted output can still be retrieved using the OSTREE_DUMP_RAW
flag, and the non-formatted key name is always printed for clarity.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #826
Approved by: cgwalters
Philip Withnall [Thu, 4 May 2017 10:31:50 +0000 (11:31 +0100)]
ostree: Add --view mode to `ostree summary`
This allows a locally generated summary file to be viewed. It accepts
the same arguments as `ostree remote summary` (i.e. --raw).
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #826
Approved by: cgwalters
Philip Withnall [Thu, 4 May 2017 10:01:41 +0000 (11:01 +0100)]
libostree: Document endianness of GVariant metadata types
Endianness strikes again.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #826
Approved by: cgwalters
Philip Withnall [Tue, 2 May 2017 21:22:15 +0000 (22:22 +0100)]
libostree: Add some additional metadata to the summary file
• Commit timestamps, so it’s easy to work out whether a given commit is
newer than the one we have locally
• Summary file timestamp, so it’s easy to work out whether the summary
file is more up to date than another summary file
• Summary file expiry time, so clients can work out when they should
expect the summary file to next be updated, and hence can query for
it at roughly the right time
The expiry time requires input from the user, so is currently never set
automatically. Programs using libostree can set it if they wish.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #826
Approved by: cgwalters
Sjoerd Simons [Tue, 2 May 2017 19:23:08 +0000 (21:23 +0200)]
repo/commit: Fix memory leak
While running the testsuite under valgrind a small memory leak showed up:
==16487== 65 bytes in 1 blocks are definitely lost in loss record 773 of 1,123
==16487== at 0x4C2BBAF: malloc (vg_replace_malloc.c:299)
==16487== by 0x6048E08: g_malloc (gmem.c:94)
==16487== by 0x6062EAE: g_strdup (gstrfuncs.c:363)
==16487== by 0x54CE3E6: write_object (ostree-repo-commit.c:776)
==16487== by 0x54CF2D4: ostree_repo_write_metadata (ostree-repo-commit.c:1528)
==16487== by 0x54CF505: _ostree_repo_write_directory_meta (ostree-repo-commit.c:1712)
==16487== by 0x54D0AB4: write_dfd_iter_to_mtree_internal (ostree-repo-commit.c:2650)
==16487== by 0x54D0E2D: ostree_repo_write_dfd_to_mtree (ostree-repo-commit.c:2793)
==16487== by 0x1190C4: ostree_builtin_commit (ot-builtin-commit.c:474)
==16487== by 0x11F2EE: ostree_run (ot-main.c:200)
==16487== by 0x116F32: main (main.c:78)
The reason for this is that ot_checksum_instream_get_string returns a chunk of newly allocated memory which never got freed.
Make actual_checksum something that gets autocleanend and own the memory
assigned to it in all cases.
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Closes: #827
Approved by: pwithnall
Colin Walters [Fri, 5 May 2017 14:44:49 +0000 (10:44 -0400)]
tree-wide: Convert to using autoptr(GString) vs g_string_free(...,TRUE)
If we're freeing the segment, it's basically always better to use
`autoptr()`. Fewer lines, more reliable, etc.
Noticed an instance of this in the pull code while reviewing a different PR,
decided to do a grep for it and fix it tree wide.
Closes: #836
Approved by: pwithnall
Philip Withnall [Fri, 5 May 2017 14:17:13 +0000 (15:17 +0100)]
libostree: Ensure progress keys are all always set
If one of the progress keys is set in a pull operation, a ::changed
signal is emitted on the progress object, and the callback for that
could query any of the progress keys — so they all need to be set,
otherwise we get an assertion failure in ostree_async_progress_get() due
to a named key not existing.
Spotted by Dan Nicholson in PR #819.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #835
Approved by: cgwalters
Philip Withnall [Fri, 5 May 2017 14:16:46 +0000 (15:16 +0100)]
libostree: Fix potential use of uninitialised memory in progress API
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #835
Approved by: cgwalters
Dan Nicholson [Wed, 3 May 2017 16:31:58 +0000 (11:31 -0500)]
pull: Fix crash specifying override URL in summary fetch
The summary URL override is looked up with "&s", which directly
exchanges the data to a pointer without allocation. This was causing a
segfault calling ostree_repo_remote_fetch_summary_with_options from
pygobject.
Closes: #829
Approved by: jlebon
Philip Withnall [Tue, 2 May 2017 21:33:04 +0000 (22:33 +0100)]
libostree: Add missing checks for invalid timestamps
g_date_time_new_from_unix_utc() will not always return a valid GDateTime
— if the input timestamp is too big, GDateTime cannot represent it, and
the constructor returns NULL.
Add some missing checks for these situations. We don’t ever expect
timestamps to be this big, but they could be as a result of corruption
or a malicious repository.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #825
Approved by: cgwalters
Philip Withnall [Wed, 3 May 2017 13:58:07 +0000 (14:58 +0100)]
libostree: Fix a typo in docs for ostree_repo_pull_with_options()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #828
Approved by: cgwalters
Colin Walters [Fri, 28 Apr 2017 20:00:49 +0000 (16:00 -0400)]
repo: Delete the last use of GFile tmp_dir
The keyring isn't large, so let's just fall back to copying it
rather than requiring `renameat()`.
Prep for `ostree_repo_open_at()`.
Closes: #821
Approved by: jlebon
Colin Walters [Fri, 28 Apr 2017 22:02:22 +0000 (18:02 -0400)]
checkout: Dedup calls to memcache ref
Minor, but I realized `checkout_tree_at()` is a better place to
do common setup before checkout. Prep for
https://github.com/ostreedev/ostree/pull/813
Closes: #823
Approved by: jlebon
Colin Walters [Fri, 28 Apr 2017 20:58:34 +0000 (16:58 -0400)]
ci: Fix flatpak test pkg install
Closes: #822
Approved by: jlebon
Philip Withnall [Fri, 28 Apr 2017 18:32:17 +0000 (19:32 +0100)]
libostree: Get and set OstreeAsyncProgress:status atomically
Use the new well-known `status` key for OstreeAsyncProgress to get and
set the status atomically with other keys in an OstreeAsyncProgress
instance.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #819
Approved by: cgwalters
Philip Withnall [Fri, 28 Apr 2017 18:04:29 +0000 (19:04 +0100)]
libostree: Allow OstreeAsyncProgress:status to be set atomically
Rework how the status is handled in OstreeAsyncProgress so that it’s now
a well-known key in the hash table. This means that it can be retrieved
and set atomically with other keys using
ostree_async_progress_[get|set]().
The behaviour of ostree_async_progress_[get|set]_status() is preserved,
with the caveat that `status` can now also be accessed using the other
API on OstreeAsyncProgress, and has to be accessed with the right
GVariant type.
Internally, a NULL status is represented by an empty status string
(since ostree_async_progress_[get|set]_variant() deliberately don’t
allow NULL variants to be set against keys, since that would break the
ostree_async_progress_get() API).
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #819
Approved by: cgwalters
Philip Withnall [Fri, 28 Apr 2017 15:24:00 +0000 (16:24 +0100)]
src: Port to new OstreeAsyncProgress atomic API
This will eliminate most of the potential races in progress reporting.
ostree_repo_pull_default_console_progress_changed() still calls three
getters, so there may still be races there, however.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #819
Approved by: cgwalters
Philip Withnall [Fri, 28 Apr 2017 15:18:55 +0000 (16:18 +0100)]
libostree: Add multiple getter/setter support to OstreeAsyncProgress
OstreeAsyncProgress is thread-safe: it can have keys changed by one
thread while another is getting the same keys (modulo some locking
contention). However, the thread safety is done at the function call
level: if some code calls an OstreeAsyncProgress getter several times,
the key fetches are not atomic with respect to each other.
In the case of contention on the lock, this can result in consumers of
OstreeAsyncProgress data seeing an inconsistent state between the
properties they query, which could result in progress reporting
inaccuracies.
In the uncontested case, this results in the OstreeAsyncProgress lock
being locked and unlocked many times more than necessary.
Try to improve this by adding new API, which supports getting and
setting multiple keys atomically:
• ostree_async_progress_get()
• ostree_async_progress_set()
The new API uses GVariants and varargs: keys are passed as a
GVariantType string followed by arguments as for g_variant_new() or
g_variant_get(), followed by the next key, etc.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #819
Approved by: cgwalters
Philip Withnall [Fri, 28 Apr 2017 15:06:40 +0000 (16:06 +0100)]
libostree: Rework OstreeAsyncProgress to use GVariants internally
OstreeAsyncProgress currently does some contortions to try and avoid
allocating space for guints and guint64s (on 64-bit platforms), but this
means it uses two GHashTables. A GHashTable allocates 8 buckets even
when empty. Given that the largest usage of OstreeAsyncProgress in
libostree puts 13 uints and 5 uint64s in it, this optimisation does not
save significant (if any) memory.
Instead, change OstreeAsyncProgress to store values internally as
GVariants, and expose this with some new API:
• ostree_async_progress_get_variant()
• ostree_async_progress_set_variant()
Each GVariant is allocated on the heap. As they are immutable, they are
thread-safe once returned by a getter.
The existing API continues to work as before, except in the case where a
key is set/got as both a uint and a uint64 — there will now be a
collision (and a GVariant type checking failure) whereas previously
there was no collision. Nothing in OSTree uses OstreeAsyncProgress this
way though.
The new API can be used to share more complex data via the progress API.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Closes: #819
Approved by: cgwalters